#include <bits/stdc++.h>

using namespace std;
#define int long long
const int inf = 0x3f3f3f3f3f3f3f3f;

void solve()
{
    int k;
    cin >> k;
    if (k == 0) cout << 1 << endl;
    else if (k == 1) cout << 4 << endl;
    else if (k == 2) cout << 8 << endl;
    else
    {
        if (k & 1)
        {
            cout << 4;
            for (int i = 0; i < (k - 1) / 2; i++) cout << 8;
            cout << endl;
        }
        else
        {
            for (int i = 0; i < k / 2; i++) cout << 8;
            cout << endl;
        }
    }
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int _ = 1;
    cin >> _;
    while (_--)
    {
        solve();
    }
    return 0;
}